package com.xiaoxu.content.controller;

import com.xiaoxu.content.model.dto.BindTeachplanMediaDto;
import com.xiaoxu.content.service.TeachplanMediaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author xiaoxu
 * @version 1.0
 * @description TODO
 * @date 2023/1/26 15:43
 */
@RestController
@Api(value = "课程计划编辑接口", tags = "课程计划编辑接口")
public class TeachplanMediaController {

    private final TeachplanMediaService teachplanMediaService;

    public TeachplanMediaController(TeachplanMediaService teachplanMediaService) {
        this.teachplanMediaService = teachplanMediaService;
    }


    @ApiOperation(value = "课程计划和媒资信息绑定")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody @Validated BindTeachplanMediaDto bindTeachplanMediaDto) {
        teachplanMediaService.associationMedia(bindTeachplanMediaDto);
    }

    @ApiOperation(value = "课程计划和媒资信息绑定删除")
    @DeleteMapping("/teachplan/association/media/{teachplanId}/{teachplanMediaId}")
    public void removeAssociationMedia(@PathVariable Long teachplanId,@PathVariable Long teachplanMediaId){
        teachplanMediaService.deleteAssociation(teachplanId,teachplanMediaId);
    }
}
